//
//  starView.m
//  WXMovie
//
//  Created by apple on 16/3/30.
//  Copyright © 2016年 zic_magic. All rights reserved.
//

#import "starView.h"

@implementation starView

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        [self _createSubviews];
        self.backgroundColor = [UIColor clearColor];
    }
    
    return self;
}


- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self _createSubviews];
        self.backgroundColor = [UIColor clearColor];

    }
    return self;
}
//- (void)awakeFromNib {
//    
//    [super awakeFromNib];
//    self.height = kScreenWidth / 14;
//    [self _createSubviews];
//    self.backgroundColor = [UIColor clearColor];
//    
//}

- (void)_createSubviews {
    
    grayView = [[UIView alloc] init];
    yellowView = [[UIView alloc] init];
    [self addSubview:grayView];
    [self addSubview:yellowView];
    
    UIImage *image = [UIImage imageNamed:@"yellow"];
    float scale = self.height / (image.size.height + 0.5);
    
    grayView.transform = CGAffineTransformMakeScale(scale, scale);
    yellowView.transform = CGAffineTransformMakeScale(scale, scale);
    
    grayView.frame = CGRectMake(0, 0, 5 * self.height, self.height);
    yellowView.backgroundColor = [UIColor colorWithPatternImage:image];
    grayView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"gray"]];
    
    
    
}

- (void)changeStarViewWidthWithRating:(float)rating {
    
    yellowView.frame = CGRectMake(0, 0, 5 * self.height *rating / 10, self.height);
}

@end
